package xxy.com.customview.view;

import android.content.Context;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * Created by Administrator on 2017/12/8.
 */

public class MyRecyclerView extends RecyclerView {
    private Intercept mIntercept;

    public MyRecyclerView(Context context) {
        super(context);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        if (mIntercept != null) {
            mIntercept.mInterceptMotionEvent(e);
        }
        return super.onInterceptTouchEvent(e);
    }

    public interface Intercept {
        void mInterceptMotionEvent(MotionEvent motionEvent);
    }

    public void setIntercept(Intercept intercept) {
        this.mIntercept = intercept;
    }
}
